<template>
	<view>

	<view class="content">
	<u-empty :text="$t('nologin')" mode="data"  icon="https://i.yodin.com/storage/empty/permission.png" v-if="!hasLogin"></u-empty>
	<view v-else>
		<u-empty :text="zjtxt" mode="data"  icon="https://i.yodin.com/storage/empty/data.png"></u-empty>
	</view>

	</view>

	</view>
</template>

<script>

import socket from '@/plugins/socket.js';
import {mapState,mapMutations} from 'vuex';
import { api_chat_friendlist,api_chat_sendmsg,api_chat_listmsg,api_chat_create_roomgroup } from '@/config/api.js';
export default {
    components:{
        
    },
	data() {
		return {
			loadstatus:false,
			loadStatus: "loadmore",
			hasLogin:false,
			zjtxt:'正在转接服务...'
		};
	},
	computed:{
	    ...mapState(['PrimaryColor','userInfo','siteInfo']),
	},
	onLoad(e) {
		this.hasLogin = this.userInfo.token;
		if (this.hasLogin)this.linkTo(e)
	},

	methods: {
		createroom(option){
				return new Promise((resolve, reject) => {
					api_chat_create_roomgroup( {
						roomnumber:option.roomid,
						form_uid:option.member_id,
						roomname:option.roomname
				}).then(res => {
					console.log('res',res)
						uni.setNavigationBarTitle({title: res.roomname});
						this.is_cun=res.is_cun;
						resolve(true);
				}).catch((e)=>{});
				});	
			},

	async linkTo(item) {
			// if(item.guru==this.userInfo.member_id){
			// 	return this.$tools.msg('不可自说自话');
			// }
		console.log('userInfo',this.userInfo)
		if(item.guru>0){
			
			
			let msgid = 'GR'+item.guru+this.userInfo.member_id
			let rname = item.roomname
			let option = {
				roomid:msgid,
				member_id:item.guru,
				roomname:rname
			}
			let zt= await this.createroom(option)
			
			if(zt)this.$tools.goJump('/pagesPackageA/chat/chat',{messageId:msgid,roomname:rname},!this.userInfo.token,'redirect')
		}else{
			this.zjtxt="错误服务"
		}

		},
	},
	
};
</script>

<style lang="scss" scoped>
.content {
	padding-bottom: 50px;
	.item {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		align-items: center;
		justify-content: flex-start;
		image {
			width: 76rpx;
			height: 76rpx;
			margin: 20rpx;
			border-radius: 12rpx;
			flex: 0 0 76rpx;
		}
		.right {
			overflow: hidden;
			flex: 1;
			padding: 20rpx 20rpx 20rpx 0;
			&_top {
				flex-direction: row;
				justify-content: space-between;
				&_name {
					color: $u-main-color;
					flex: 0 0 350rpx;
					overflow: hidden;
				}
				&_time {
					font-size: 22rpx;
					color: $u-tips-color;
				}
			}
			&_btm {
				flex-direction: row;
				justify-content: space-between;
				align-items: center;
				font-size: 22rpx;
				color: $u-tips-color;
				padding-top: 10rpx;
			}
		}
	}
	.bg_view {
		background-color: #fafafa;
	}
	.slot-wrap {
		display: flex;
		align-items: center;
		padding: 0 30rpx; 
	}
}
</style>
